// createRouter: 创建router 实例对象
// createWebHistory: 创建History模式的路由
import { createRouter, createWebHistory } from 'vue-router'
// 导入首页
import Login from '@/views/Login/index.vue'
// 导入登录页
import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
import Category from '@/views/Category/index.vue'
import SubCategory from '@/views/SubCategory/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: Login,
    },
    {
      path: '/',
      name: 'index',
      component: Layout,
      children: [
        {
          path:'',  // 默认组件，path 去空
          name: 'home',
          component: Home,
        },
        {
          path: "category/:id",
          name: "category",
          component: Category,
        },
        {
          path: 'category/sub/:id',
          name: 'subCategory',
          component: SubCategory
        },

      ]
    }
  ],
})

export default router
